﻿//using BaseUtils.Helper;
//using DatabaseCore.Sqlite;
//using Service.src.Flow.Server;
//using Service.src.NW.Enum;
//using Service.src.NW.Model.Drive;
//using System.Collections.Generic;
//using System.Runtime.InteropServices;


//namespace Service.src.Flow.Api
//{

//    [ComVisible(true)]
//    [ClassInterface(ClassInterfaceType.AutoDual)]
//    public class SysPlcDriverAddressApi
//    {
//        public static SysPlcDriverAdressServer AddressServer;

//        public SysPlcDriverAddressApi()
//        {
//            AddressServer = new SysPlcDriverAdressServer();
//        }

//        /// <summary>
//        /// 添加Address，更新Address
//        /// </summary>
//        /// <param name="DriveJson"></param>
//        /// <returns></returns>
//        public string Install(string AddressJson)
//        {
//            SysPlcDriverAddress Address = ConvertHelper2.ToObject<SysPlcDriverAddress>(AddressJson);
//            Address.DriverType = DeviceTypeEnum.PLC;
//            if (Address != null && Address.Id > 0 && !string.IsNullOrEmpty(Address.Id.ToString()))
//            {
//                AddressServer.UpldateAddress(SqliteHelper.SystemDefaultDBID, Address);
//            }
//            else
//            {
//                Address = AddressServer.AddAddress(SqliteHelper.SystemDefaultDBID, Address);
//            }

//            return Address.ToJson();
//        }

//        /// <summary>
//        /// 根据 ID 删除Address
//        /// </summary>
//        /// <param name="Id"></param>
//        /// <returns></returns>
//        public bool Delete(int Id)
//        {
//            return AddressServer.DeleteAddress(SqliteHelper.SystemDefaultDBID, Id);
//        }

//        /// <summary>
//        /// 获取对应plc的Address
//        /// </summary>
//        /// <returns></returns>
//        public string Query(int DriverId)
//        {
//            if (DriverId <= 0)
//            {
//                return "[]";
//            }
//            List<SysPlcDriverAddress> Address = AddressServer.GetAddresslist(SqliteHelper.SystemDefaultDBID, DriverId);
//            if (Address == null || Address.Count <= 0)
//            {
//                return "[]";
//            }
//            return Address.ToJson();
//        }
//        /// <summary>
//        /// 获取所有plc Address
//        /// </summary>
//        /// <returns></returns>
//        public List<SysPlcDriverAddress> Query()
//        {
//            List<SysPlcDriverAddress> Address = AddressServer.GetAllAddresslist(SqliteHelper.SystemDefaultDBID);
//            return Address;
//        }

//        /// <summary>
//        /// 获取PLC地址
//        /// </summary>
//        /// <param name="DriverType"></param>
//        /// <returns></returns>
//        public string QueryByDriverType(string DriverType)
//        {
//            List<SysPlcDriverAddress> Address = AddressServer.QueryByDriverType(SqliteHelper.SystemDefaultDBID,DriverType);
//            if (Address == null || Address.Count <= 0)
//            {
//                return "[]";
//            }
//            return Address.ToJson();
//        }

//        /// <summary>
//        /// 根据 ID 获取Address详情数据
//        /// </summary>
//        /// <param name="Id"></param>
//        /// <returns></returns>
//        public string Get(int Id)
//        {
//            SysPlcDriverAddress info = AddressServer.GetAddressInfoById(SqliteHelper.SystemDefaultDBID, Id);
//            return info.ToJson();
//        }

//    }
//}
